package com.atguigu.tingshu.album.api;

import com.alibaba.fastjson.JSONObject;
import com.atguigu.tingshu.album.service.BaseCategoryService;
import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.model.album.BaseAttribute;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Tag(name = "分类管理")
@RestController
@RequestMapping(value = "/api/album/category")
@SuppressWarnings({"all"})
public class BaseCategoryApiController {

    @Autowired
    private BaseCategoryService baseCategoryService;

    @Operation(summary = "获取分类数据")
    @GetMapping(value = "/getBaseCategoryList")
    public Result getBaseCategoryList() {
        List<JSONObject> list = baseCategoryService.getBaseCategoryList();
        return Result.ok(list);
    }

    @Operation(summary = "根据一级分类标签id获取属性标签")
    @PostMapping(value = "/findAttribute/{category1Id}")
    public Result findAttribute(@PathVariable Long category1Id) {
        List<BaseAttribute> list = baseCategoryService.findAttribute(category1Id);
        return Result.ok(list);
    }

}

